<?php


namespace app\system\controller;

class Index extends AdminBase
{
	public function getmenu()
	{
		$menu = \app\system\service\MenuService::getMenuTree($this->admin_info);
		$this->response(\app\system\model\Code::success, "获取成功", $menu);
	}
	public function getauth()
	{
		$where = ["role_id" => $this->admin_info["role_id"]];
		$ids = \think\Db::name("system_admin_role_auth")->where($where)->column("menu_auth_id");
		if ($this->admin_info["root"] == 1) {
			$lists = \think\Db::name("system_admin_menu")->where(["type" => 2, "disable" => 0])->order(["sort" => "desc"])->select();
		} else {
			$lists = \think\Db::name("system_admin_menu")->where(["type" => 2, "disable" => 0])->whereIn("id", $ids)->order(["sort" => "desc"])->select();
		}
		$this->response(\app\system\model\Code::success, "获取成功", $lists);
	}
	public function get_self_info()
	{
		$admin = $this->admin_info;
		$role = \think\Db::name("system_admin_role")->where(["id" => $admin["role_id"]])->find();
		$data = ["account_info" => ["name" => $admin["name"], "account" => $admin["account"]], "role_info" => ["id" => !$admin["role_id"] ? "0" : $role["id"], "name" => !$admin["role_id"] ? "超级管理员" : $role["name"]]];
		$this->response(\app\system\model\Code::success, "获取成功", $data);
	}
	public function get_index_data()
	{
		$result = \app\system\service\IndexService::get_index_data([]);
		$this->response(\app\system\model\Code::success, "获取成功", $result);
	}
}